﻿using System;

namespace BaseSyntax.Copy
{
	public class ShallowCopy:ITest
	{
		public int i = 2;
		
		public object GetCopy()
		{
			return MemberwiseClone();
		}

		public void Test()
		{
			// 对于值类型，可以正常的使用
			// 但是如果涉及到引用类型，则无法做拷贝
			ShallowCopy c1 = new ShallowCopy();
			c1.i = 2;
			ShallowCopy c2 = (ShallowCopy)c1.GetCopy();
			c2.i = 3;
			Console.WriteLine($"{c1.i} {c2.i}");
		}
		
	}
}